<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body onkeyup="method01(event)">
<hr id="myHr" style="width: 50px;height: 50px;background-color: red" >
</body>
<script>
    var width = 50;
    var height = 50;

  function method01(event){
      console.log(event);
      console.log(event.key);
      console.log(event.keyCode);
      let myHr = document.getElementById("myHr");

      if (event.key ==="a") {
          width -=10;
          height -=10;
      }
      else if (event.key ==="d"){
          width+=10;
          height+=10;
      }
      console.log(myHr.style.cssText);
      myHr.style.cssText = "width: "+ width +"px;height: "+ height +"px;background-color:yellow";
  }
</script>
</html>